package com.java.zhuiyun.api.houserank.controller;

import com.java.zhuiyun.annotation.OptLog;
import com.java.zhuiyun.api.houserank.entity.HouseRank;
import com.java.zhuiyun.api.houserank.service.HouserankService;
import com.java.zhuiyun.common.response.CommonConstants;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName HouserankController
 * @Description TODO
 * @Author wuwan
 * @Date 2023/9/14 9:57
 **/
@RestController
@RequestMapping("/Houserank")
public class HouserankController {
    @Autowired
    private HouserankService houserankService;
    /*
     * @Author wuwan
     * @Description 角色等级查询
     * @Date 2023/9/13 20:07
     * @Return
     * @param null
     */
    @GetMapping("/selectHouserank")
    @OptLog(modular = "房屋管理",type = CommonConstants.SELECT,describe = "分页查询房屋信息")
    public CommonResult selectHouserank(PageRequest pageRequest){
        return CommonResult.ok(houserankService.selectHouserank(pageRequest));
    }
    /*
     * @Author wuwan
     * @Description 角色添加
     * @Date 2023/9/13 20:07
     * @Return
     * @param null
     */
    @PostMapping("/addHouserank")
    @OptLog(modular = "房屋管理",type = CommonConstants.ADD,describe = "新增房屋信息")
    public CommonResult addHouserank(MultipartFile file, HouseRank houseRank){
        return CommonResult.ok(houserankService.addHouserank(file,houseRank));
    }
    /*
     * @Author wuwan
     * @Description 角色修改
     * @Date 2023/9/14 9:03
     * @Return
     * @param null
     */
    @PostMapping("/updateHouserank")
    @OptLog(modular = "房屋管理",type = CommonConstants.UPDATE,describe = "修改房屋信息")
    public CommonResult updateHouserank(MultipartFile file,HouseRank houseRank){
        return CommonResult.ok(houserankService.updateHouserank(file,houseRank));
    }
    /*
     * @Author wuwan
     * @Description 查询当前用户房屋信息
     * @Date 2023/10/8 11:06
     * @Return
     */
    @GetMapping("/getHouseData")
    @OptLog(modular = "房屋管理",type = CommonConstants.SELECT,describe = "查询当前用户的房屋信息")
    public CommonResult getHouseData( String openid){
        return CommonResult.ok(houserankService.getHouseData(openid));
    }
}
